<template>
  <div class="app-container" style="padding: 0">
    <el-table v-loading="loading" :data="dataList" :border="true" :header-row-style="{height: '60px'}" :header-cell-style="{fontSize: '18px'}" :row-style="{height:'60px',fontSize: '16px'}">
      <el-table-column label="区域" prop="position" fixed />
      <el-table-column label="当前" prop="current" fixed />
      <el-table-column label="1分钟" prop="oneMinute" fixed />
      <el-table-column label="5分钟"  prop="fiveMinute"  />
      <el-table-column label="10分钟"  prop="tenMinute"  />
      <el-table-column label="30分钟"  prop="thirtyMinute"  />
    </el-table>

  </div>
</template>

<script setup name="Current">

import { averageThickness } from "@/api/coal/realtimeData";

const props = defineProps({
  deviceId: {
    type: Number,
    default: null,
  },
})

const { proxy } = getCurrentInstance();

const dataList = ref([]);
const loading = ref(true);

let currentTable = ref<String>("");


onMounted(() => {
  getList()
  currentTable = setInterval(()=>{
    getList()
  },1000*60)
})
/** 查询设备表列表 */
function getList() {
  loading.value = true;
  averageThickness(props.deviceId).then(response => {
    if (response.data){
      dataList.value = response.data;
    }
    loading.value = false;
  });
  loading.value = false
}

onBeforeUnmount(() => {
  clearInterval(currentTable)
})
</script>

